{extend name="../../common/view/admin_base"/}

{block name="main"}
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body">
                    <div class="layui-form">
                        <table class="layui-table layui-form" id="table" lay-filter="datatable" lay-size="sm"></table>
                        <button class="layui-btn layui-hide" lay-submit lay-filter="commit" id="layui-submit">提交</button>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['layer','table','form'], function() {
        var layer = layui.layer;
        var table = layui.table;
        var form = layui.form;

        table.render({
            elem: '#table'
            ,url:document.URL
            ,cellMinWidth: 80
            ,cols: [[
                {type:'checkbox'}
                ,{field:'name', title:'名称',width:160}
                ,{field:'remark', title:'摘要',width:300}
                ,{field:'action', title:'操作',templet: '#actionTpl', unresize: true}
            ]]
            ,height: 'full-80'
            ,page: false
            ,response: {
                statusCode: 200 //重新规定成功的状态码为 200，table 组件默认为 0
            }
            ,parseData: function(res){ //将原始数据解析成 table 组件所规定的数据
                return {
                    "code": 200,
                    "msg": res.msg,
                    "data": res.data
                };
            }
        });

        form.on('submit(commit)', function(obj){
            var checkStatus = table.checkStatus('table')
                ,data = checkStatus.data;
            var gid = [];
            for(var i=0;i<data.length;i++){
                gid.push(data[i].guid);
            }
            $.post(document.URL,{gid:gid},function(res){
                layer.msg(res.msg,{
                    offset: '15px'
                    ,icon: 1
                    ,time: 1000
                },function(){
                    top.layer.closeAll();
                });
            });
        });

    });

</script>

{/block}